Skip to content

feat: replace browser reload with in-place reset for VS "New" diagram#16

Open
DisciplinedSoftware wants to merge 1 commit into
OlegIGalkin:mainfrom
DisciplinedSoftware:feat/vs-new-without-reload
Open

feat: replace browser reload with in-place reset for VS "New" diagram#16
DisciplinedSoftware wants to merge 1 commit into
OlegIGalkin:mainfrom
DisciplinedSoftware:feat/vs-new-without-reload

Conversation

@DisciplinedSoftware
Copy link
Copy Markdown

Motivation

The VS Code and Visual Studio plugins previously handled the "New diagram" action differently:

  • VS Code — the webview is persistent, so "New" calls mind.refresh(defaultData) + mind.clearHistory() on the existing mind instance.
  • Visual Studio — "New" called MindMapBrowser.Reload(), which destroyed and recreated the entire browser context, resetting history as a side effect.

This PR aligns the Visual Studio plugin with the VS Code approach so both plugins use the same mechanism: an in-place mind.refresh() + mind.clearHistory().

Changes

CodeMindMapHtml.cs

Added a window.resetMindMap() JS function that:

  1. Builds the same default node tree used during initMindMap()
  2. Applies the direction before calling mind.refresh() (same workaround already used in importData)
  3. Calls mind.refresh(defaultData) + mind.clearHistory()
  4. Resets the theme to Light if needed

MindMapToolWindowControl.xaml.cs

Changed NewCodeMindMapClick to call await MindMapBrowser.ExecuteScriptAsync("resetMindMap()") instead of ReloadMindMapBrowser(). The C# side (package data management) is unchanged.

Result

Both plugins now reset the mind map in-place without a full browser reload. History is cleared explicitly via clearHistory() in both cases.

Copilot AI review requested due to automatic review settings March 11, 2026 06:00
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@DisciplinedSoftware DisciplinedSoftware force-pushed the feat/vs-new-without-reload branch from 21d466f to 6068d6b Compare March 24, 2026 02:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants